package com.creator.pangu.common.enums;


public enum HTTPStatusCode {

    SUCCESS(200,"操作成功!"),
    UNAUTHORIZED(401,"认证失败!"),
    FORBIDDEN(403,"没有权限!"),
    NOT_FOUND(404,"资源不存在!"),
    METHOD_NOT_ALLOWED(405,"请求方式不允许!"),
    ERROR(500,"系统错误!");



    private Integer code;
    private String msg;

    HTTPStatusCode(Integer code, String msg) {
        this.code= code;
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public static String getMsgByCode(Integer code) {
        for (HTTPStatusCode httpStatusCode : values()) {
            if (httpStatusCode.getCode().equals(code)) {
                return httpStatusCode.getMsg();
            }
        }
        return null;
    }
}
